package cn.jwcat.controller;

import cn.jwcat.entity.Ipaddress;
import cn.jwcat.service.IIpaddressService;
import cn.jwcat.utils.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * ip地址操作
 */
@Transactional
@RestController
@RequestMapping("/ipaddress")
public class IpaddressController {
	@Resource
	IIpaddressService ipaddressService;

	@GetMapping("/{page}/{size}")
	@ApiOperation("ip地址的分页查询")
	public Result suppliesPage(@PathVariable("page") int page, @PathVariable("size") int size) {
		PageHelper.startPage(page, size);
		List<Ipaddress> ip = ipaddressService.list();
		PageInfo<Ipaddress> ipaddressPageInfo = new PageInfo<>(ip);
		return Result.success(ipaddressPageInfo);
	}
}
